Skip to content

oracle-visualvm-issues-623 Added JAVA_HOME to visulavm luncher & conf #643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

dasarathirout
Copy link
Member

@dasarathirout dasarathirout commented Jul 29, 2025

oracle-visualvm-issues-#623 Added JAVA_HOME to visulavm luncher & conf

  • use JAVA_HOME env var
S2-Use-JavaHome-Env
  • Override with --jdkhome argument
S1-Override-JavaHome

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jul 29, 2025
@@ -63,7 +63,11 @@ esac


if [ -f "$progdir"/../lib/visualvm/etc/visualvm.conf ] ; then
visualvm_jdkhome="$basedir"
if [[ -d "$JAVA_HOME" && -f "$JAVA_HOME/bin/java" ]]; then
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Windows version also takes JDK_HOME into consideration, maybe it would be better to have the same behaviour.

# Check if JAVA_HOME is set and valid
elif [ -n "${JAVA_HOME}" ] && [ -d "${JAVA_HOME}" ] && [ -f "${JAVA_HOME}/bin/java" ]; then
visualvm_jdkhome="${JAVA_HOME}"
fi

if [ -f "$progdir"/../lib/visualvm/etc/visualvm.conf ] ; then
visualvm_jdkhome="$basedir"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this overwrite the visualvm_jdkhome if the config file is present, even if visualvm_jdkhome is not defined in it ?

We only want to override JAVA_HOME if visualvm.conf is found AND visualvm_jdkhome is defined in it.

Copy link
Member Author

@dasarathirout dasarathirout Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate any insights or corrections you might have.

Won't this overwrite the visualvm_jdkhome if the config file is present, even if visualvm_jdkhome is not defined in it ?

Setting default value for luncher visualvm_jdkhome based on JDK_HOME or JAVA_HOME env.
after we check for visualvm_jdkhome in visualvm.conf (it might not be defined here ) and overide with privious JDK_HOME or JAVA_HOME env any.

We only want to override JAVA_HOME if visualvm.conf is found AND visualvm_jdkhome is defined in it.
My understanding bellow order

  1. we default to env var
  2. then visualvm.conf configuration (if defined , else env )
  3. --jdkhome argument override env & conf

Env set with conf
SS-default

Has env set & conf but ovrride with args
SS-with-args

Only env set , no conf disabled
SS-no-conf

Copy link

@stoty stoty Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your second example covers the case when the config file is in etc/
But line 66/73 overwrites the variable you set in the patch if the config file is found in lib/

if [ -f "$progdir"/../lib/visualvm/etc/visualvm.conf ] ; then visualvm_jdkhome="$basedir"

Copy link

@stoty stoty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 LGTM.

Note that I haven't tested this, only eyeballed.

fi
}

set_jdk_java_home_from_conf(){
Copy link

@stoty stoty Aug 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: set_jdk_java_home would be a better name, as this falls back to environment variables.

@dasarathirout
Copy link
Member Author

Hi @thurka, @jisedlac Could you please help with review ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants